package main

import (
	"kop/libs/database"
	"kop/modules/building/entity"
)

func main() {

	var db1 = database.Open("host=127.0.0.1 user=postgres password=123456 dbname=build sslmode=disable", 1, 2, true)

	defer db1.Close()

	var data []*entity.Building
	if err := db1.Find(&data).Error; err != nil {
		panic(err)
	}

	var db2 = database.Open("host=127.0.0.1 user=postgres password=123456 dbname=captain sslmode=disable", 1, 2, true)

	defer db2.Close()

	db2.AutoMigrate(new(entity.Building))

	for _, v := range data {
		db2.Create(v)
	}

	db1.Delete(&entity.Building{})
}
